import { API_URL } from '../../constants/api'

const sendVerificationCode = (data) => {
  return uni.request({
    url: `${API_URL}/auth/sms/send`,
    method: "POST",
    data: data
  })
}

const register = (data) => {
  return uni.request({
    url: `${API_URL}/auth/register/phone`,
    method: "POST",
    data: data
  })
}


const login = (type, data) => {
  let url = `${API_URL}/auth/login/phone/password`

  if (type === 'code') {
    url = `${API_URL}/auth/login/phone/code`
  }

  if (type === 'wechat') {
    url = `${API_URL}/auth/wechat/miniapp/login`
  }

  return uni.request({
    url: url,
    method: "POST",
    data: data
  })
}


export {
  sendVerificationCode,
  register,
  login
}